home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / basic / ActiveWindow.lha / ActiveWindow / ActiveWindow.asc next >
Encoding:
Text File  |  2000-08-30  |  1.6 KB  |  68 lines

  1.  
  2. ; $VER: ActiveWindow.bb2 v1.1 (30.08.2000)
  3.  
  4. ; Author: Damir Arh
  5. ; E-mail: damir.arh@telesat.si
  6. ; WWW:    http://damir.gajba.net/
  7.  
  8. ; This source code is completely free. You can redistribute
  9. ; and/or modify it without any restrictions whatsoever.
  10.  
  11. ;-------------------------------------------------------------
  12.  
  13. ; This source code demonstrates how to open a window which
  14. ; automaticaly activates itself as long as its screen is
  15. ; the front one.
  16.  
  17. ; The routine is particularily useful in cases where you
  18. ; open your own screen and a window on it which then
  19. ; receives all the events through IDCMP messages and also
  20. ; changes the pointer. By using this routine you can always
  21. ; know when your screen is the front one and you can
  22. ; activate the window without the user having to intervene.
  23.  
  24. ;-------------------------------------------------------------
  25.  
  26.  
  27. WBStartup
  28. WBenchToFront_
  29. FindScreen 0
  30. ; this message tells you when your window gets inactive
  31. AddIDCMP #IDCMP_INACTIVEWINDOW
  32. Window 0,10,10,300,150,#WFLG_ACTIVATE+#WFLG_DRAGBAR+#WFLG_CLOSEGADGET+#WFLG_DEPTHGADGET+#WFLG_SIZEGADGET,"ActiveWindow",1,3
  33.  
  34. While True
  35.  
  36.   Select WaitEvent
  37.  
  38.     Case #IDCMP_INACTIVEWINDOW
  39.  
  40.       ; our window is now inactive
  41.       InBack.b=True
  42.       ; wait for the screen to get in front
  43.       While InBack
  44.  
  45.         lock.l = LockIBase_(0)
  46.         *ib._IntuitionBase = IntuitionBase
  47.         *firstscreen._Screen = *ib\FirstScreen
  48.         UnlockIBase_(lock)
  49.  
  50.         If Peek.l(Addr Screen(0)) = *firstscreen
  51.           InBack.b=False
  52.         EndIf
  53.  
  54.         Delay_(20)
  55.  
  56.       Wend
  57.       ; the screen is in front - activate window
  58.       Activate 0
  59.  
  60.     Case #IDCMP_CLOSEWINDOW
  61.  
  62.       End
  63.  
  64.   End Select
  65.  
  66. Wend
  67.  
  68.